package com.ruoyi.conversationGroup.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.conversationGroup.domain.CodeConversationGroup;
import com.ruoyi.conversationGroup.service.ICodeConversationGroupService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * conversationGroupController
 * 
 * @author wubing
 * @date 2024-09-09
 */
@RestController
@RequestMapping("/conversationGroup/group")
public class CodeConversationGroupController extends BaseController
{
    @Autowired
    private ICodeConversationGroupService codeConversationGroupService;

    /**
     * 查询conversationGroup列表
     */
    @PreAuthorize("@ss.hasPermi('conversationGroup:group:list')")
    @GetMapping("/list")
    public TableDataInfo list(CodeConversationGroup codeConversationGroup)
    {
        startPage();
        List<CodeConversationGroup> list = codeConversationGroupService.selectCodeConversationGroupList(codeConversationGroup);
        return getDataTable(list);
    }

    /**
     * 导出conversationGroup列表
     */
    @PreAuthorize("@ss.hasPermi('conversationGroup:group:export')")
    @Log(title = "conversationGroup", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CodeConversationGroup codeConversationGroup)
    {
        List<CodeConversationGroup> list = codeConversationGroupService.selectCodeConversationGroupList(codeConversationGroup);
        ExcelUtil<CodeConversationGroup> util = new ExcelUtil<CodeConversationGroup>(CodeConversationGroup.class);
        util.exportExcel(response, list, "conversationGroup数据");
    }

    /**
     * 获取conversationGroup详细信息
     */
    @PreAuthorize("@ss.hasPermi('conversationGroup:group:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(codeConversationGroupService.selectCodeConversationGroupById(id));
    }

    /**
     * 新增conversationGroup
     */
    @PreAuthorize("@ss.hasPermi('conversationGroup:group:add')")
    @Log(title = "conversationGroup", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CodeConversationGroup codeConversationGroup)
    {
        return toAjax(codeConversationGroupService.insertCodeConversationGroup(codeConversationGroup));
    }

    /**
     * 修改conversationGroup
     */
    @PreAuthorize("@ss.hasPermi('conversationGroup:group:edit')")
    @Log(title = "conversationGroup", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CodeConversationGroup codeConversationGroup)
    {
        return toAjax(codeConversationGroupService.updateCodeConversationGroup(codeConversationGroup));
    }

    /**
     * 删除conversationGroup
     */
    @PreAuthorize("@ss.hasPermi('conversationGroup:group:remove')")
    @Log(title = "conversationGroup", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(codeConversationGroupService.deleteCodeConversationGroupByIds(ids));
    }
}
